﻿Imports System.Windows.Xps.Packaging

Public Class ViewModelDocument
    Inherits Common.UI.ViewModelBase
    Implements Common.UI.IViewModelTabSection

    Private docsorc As XpsDocument
    Private original As ViewModelDocument

    Public Sub New(ByVal original As ViewModelDocument)
        Me.original = original
    End Sub

    Public Sub New(ByVal path As String, ByVal Title As String, Optional ByVal Relative As Boolean = False)
        If Not Relative Then
            Me.docsorc = New XpsDocument(path, IO.FileAccess.Read)
        End If
        Me.Title = Title
    End Sub

    Public Property Icone As String Implements Common.UI.IViewModelTabSection.Icone
    Public Property Title As String Implements Common.UI.IViewModelTabSection.Title

    Public ReadOnly Property Document As Windows.Documents.IDocumentPaginatorSource
        Get
            If (Not Me.original Is Nothing) Then
                Return Me.original.Document
            End If
            Return Me.docsorc.GetFixedDocumentSequence
        End Get
    End Property

    Public Property PageNumber As Integer

    Public Property IsClosable As Boolean Implements Common.UI.IViewModelTabSection.IsClosable
End Class
